package oocl.com.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import oocl.com.pojo.Customer;
import oocl.com.service.CustomerManager;
import oocl.com.service.impl.CustomerManagerFactory;

/**
 * Servlet implementation class ListAllCustomerServlet
 */
public class ListAllCustomerServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private CustomerManager manager;
       
    public ListAllCustomerServlet() {
        super();
        manager = CustomerManagerFactory.getInstance();
        if(manager == null)
        	System.out.println(manager + "is null");
    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<Customer> customers = manager.findAllCustomer();
		request.setAttribute("customers", customers);
		request.getRequestDispatcher("list.jsp").forward(request, response);//转发到jsp界面
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}
